<?php
/*========================================= JooSam =========================================/
/																							/
/	Extention:		JooSam																	/
/	Created by:		ScriptPlanet.eu															/
/	Site:			http://www.scriptplanet.eu												/
/	Email:			support@scriptplanet.eu													/
/	Support:		http://www.scriptplanet.eu/support										/
/	Copyright:		2011 (c) ScriptPlanet.eu												/
/	License:		CC BY-NC-ND 3.0 ~ http://creativecommons.org/licenses/by-nc-nd/3.0/		/
/	File Version:	0001																	/
/																							/
/========================================== JooSam ========================================*/
// Joomla Security
defined('_JEXEC') or die;
JHTML::_('behavior.mootools');
jimport('joomla.application.component.helper');
if(JComponentHelper::isEnabled('com_joosam', true)):

	$partitle = $params->get('artTit');
	$parData = $params->get('artTxt');
	$parBg0 = $params->get('bgFirRow');
	$parBgHv0 = $params->get('bgFirRowHv');
	$parBg1 = $params->get('bgSecRow');
	$parBgHv1 = $params->get('bgSecRowHv');

	echo '<style type="text/css">';
	echo '
	.jsam_mod_populate .jsam_td .jsam_span_artist{ width:45%; margin:0; text-align:left; padding:0; color:#'.$partitle.'; }
	.jsam_mod_populate .jsam_td .jsam_span_title{ width:45%; margin:0; padding:0; text-align:left; color:#'.$parData.'; }
	.jsam_mod_populate .jsam_table{ text-align:left; width:100%; padding:0; }
	.jsam_mod_populate .jsam_row_bg0, .jsam_mod_populate .jsam_row_bg1{ margin:0 0 5px 0; }';
	if($parBg0 != 'FFFFFF' AND $parBg0 != ''){ echo '.jsam_mod_populate .jsam_row_bg0{ background:#'.$parBg0.'; margin:0; }'; }
	if($parBgHv0 != 'FFFFFF' AND $parBgHv0 != ''){ echo '.jsam_mod_populate .jsam_row_bg0:hover{ background:#'.$parBgHv0.'; }'; }
	if($parBg1 != 'FFFFFF' AND $parBg1 != ''){ echo '.jsam_mod_populate .jsam_row_bg1{ background:#'.$parBg1.'; margin:0; }'; }
	if($parBgHv1 != 'FFFFFF' AND $parBgHv1 != ''){ echo '.jsam_mod_populate .jsam_row_bg1:hover{ background:#'.$parBgHv1.'; }'; }
	echo '</style>';
	?>

	<div id="jsamRecuest"></div>

	<script>
	/*********************************************************

		Name: jsam_mod_requested
		Version: 1.0
		Script: JavaScript
		Created by: ScriptPlanet.eu - Paules
		Site: http://www.scriptplanet.eu
		Description:	This script will use ajax to show
						information about the most requested
						songs in SAM Broadcaster.

	*********************************************************/
	// make ajax object
	function jsamRecuestObject(){ var req; if(window.XMLHttpRequest){ req = new XMLHttpRequest(); } else if(window.ActiveXObject){ req = new ActiveXObject("Microsoft.XMLHTTP");} else { alert("Your browser is to old to show this page."); } return req; }
	// var that load the objects
	var jsamRec = jsamRecuestObject();
	// ajax load php for most requested
	function jsamRecuestSend(url){ jsamRec.open('post', url ,true); jsamRec.onreadystatechange = jsamRecuestHandleResponse; jsamRec.send(null); }
	// on ready jsam most requested
	function jsamRecuestHandleResponse(){ if(jsamRec.readyState == 4 && jsamRec.status == 200){ var response = jsamRec.responseText; if(response){ document.getElementById("jsamRecuest").innerHTML = response; } } }
	// window onload for most requested

	window.onload = jsamRecuestSend("<?php echo JRoute::_('index.php?option=com_joosam&view=modules&layout=populate&format=raw'); ?>");
	</script>

<?php else: ?>
	<div id="jsamRecuest">
		<div style="background:white; color:red; font-weight:bold; border-radius:10px; margin:1px; text-align:center; padding:0;">
			Component joosam is not installed.
		</div>
	</div><?php
endif;
?>